import axios from 'axios'
import storageUtils from "../../utils/storageUtils.ts"
const token = storageUtils.getStorage("token")
// axios.defaults.baseURL = "http://xawn.f3322.net:8012"

const users = {
    //获取所有用户数据
    user(params) {
        return axios({
            url: 'http://xawn.f3322.net:8012/user',
            headers: {
                Authentication: token
            },
            params
        })
    },
    //获取所有部门数据
    dept() {
        return axios({
            url: 'http://xawn.f3322.net:8012/dept',
            headers: {
                Authentication: token
            },
        })
    },
    //获取所有角色
    role(params) {
        return axios({
            url: 'http://xawn.f3322.net:8012/role',
            headers: {
                Authentication: token
            },
            params
        })
    },
    //新增用户数据
    addUser(data) {
        return axios({
            url: 'http://xawn.f3322.net:8012/user',
            method: 'POST',
            headers: {
                Authentication: token
            },
            data: data
        })
    },
    //删除用户
    delUser(userId) {
        return axios({
            url: `http://xawn.f3322.net:8012/user/${userId}`,
            method: 'delete',
            headers: {
                Authentication: token
            },
        })
    },
    //获取所有菜单数据
    menu(params) {
        return axios({
            url: 'http://xawn.f3322.net:8012/menu',
            headers: {
                Authentication: token
            },
            params
        })
    },
    //新增角色
    addRole(data) {
        return axios({
            url: 'http://xawn.f3322.net:8012/role',
            method: 'post',
            headers: {
                Authentication: token
            },
            data
        })
    },
    //删除角色
    delRole(roleId) {
        console.log(roleId);
        return axios({
            url: `http://xawn.f3322.net:8012/role/${roleId}`,
            method: 'delete',
            headers: {
                Authentication: token
            },
        })
    }
}

export default users